import Vue from 'vue'
import VueRouter from 'vue-router'

// 导入
/* import Reg from "@/views/Reg/Reg.vue"
import Login from "@/views/Login/Login.vue"
import Main from "@/views/Main/Main.vue"
import Home from "@/views/Menus/Home/Home.vue"
import UserInfo from "@/views/Menus/User/UserInfo.vue"
import UserAvatar from "@/views/Menus/User/UserAvatar.vue"
import UserPwd from "@/views/Menus/User/UserPwd.vue"
import ArtCate from "@/views/Menus/Article/ArtCate.vue"
import ArtList from "@/views/Menus/Article/ArtList.vue" */
Vue.use(VueRouter)
// 把下面的代码粘贴到路由模块中对应的位置，即可防止路由报错的问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
//路由规则
const routes = [
  {path: '/login', name:'login',component:()=>import('@/views/Login/Login.vue')},
  {path: '/reg', name:'reg',component: ()=>import('@/views/Reg/Reg.vue')},
  {
    path: '/',
    name:'main',
    component: ()=>import('@/views/Main/Main.vue'),
     // 3. 开启路由重定向
     redirect: '/home',
     children: [
       // 2. main 的 子路由规则
       { path: 'home',name:'home', component: ()=>import('@/views/Menus/Home/Home.vue') },//首页
       { path:'user-info' ,name:"user-info", component: ()=>import('@/views/Menus/User/UserInfo.vue') },//基本信息
       { path:'user-avatar',name:"user-avatar" ,component:()=>import('@/views/Menus/User/UserAvatar.vue') },
       { path:'user-pwd',name:"user-pwd",component:()=>import('@/views/Menus/User/UserPwd.vue') },
       { path:'art-cate',name:"art-cate" ,component: ()=>import('@/views/Menus/Article/ArtCate.vue') },
       {path:'art-list',name:"art-list", component: ()=>import('@/views/Menus/Article/ArtList.vue')}
     ]
  },
]

const router = new VueRouter({
  routes
})

export default router
